<?php
 
require_once('../../../../wp-config.php');
require_once('../../../../wp-includes/functions.php');

global $table_prefix, $wpdb, $post;
$table_name = $wpdb->prefix."comments";
$diggc_log = $wpdb->prefix."undiggc_log";

$commid = $_REQUEST['rid'];
$userid = $_REQUEST['aid'];
$ip=getenv("REMOTE_ADDR");
$date=date("Y-m-d H:i:s");

$result = $wpdb->get_results("SELECT * FROM $diggc_log WHERE userid =".$userid." and cid =".$commid);
if(empty($result))
{
    if($userid != 0)
    {
        $sql="INSERT INTO $diggc_log (userid, cid, ip, time) VALUES ('" .$userid. "','".$commid. "','" .$ip. "','" . $date. "')";
        $r = mysql_query($sql);
        if($r)
        {
            add_comment_meta($commid, '_undigg',0,true);
            $collect_count = get_comment_meta($commid, '_undigg', true);
            if($collect_count != null)
            {
                $collect_count = $collect_count+1;
                update_comment_meta($commid, '_undigg', $collect_count);
            }
            echo 'OK';    
        }
        else
        {
            echo '数据存储失败';
            
        }
     }
     else
     {
        echo '请先进行登录！';
     }   
}
else
{
    
    echo '已反对';

}
?>